package com.caocaog.market.data.transfer.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.caocaog.market.data.transfer.entity.*;
import com.caocaog.market.data.transfer.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.CommonAPI;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CacheConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.system.vo.LoginUserSite;
import org.jeecg.common.system.vo.LoginUserSiteArea;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.sql.ResultSet;
import java.util.List;

/**
 * @author liguang
 * @version 1.0.0
 * @Project jeecg-boot
 * @Package com.caocaog.market.data.transfer.controller
 * @ClassName DataTransferController.java
 * @createTime 2021年11月16日 10:55:00
 * @Description 分站列表
 */
@Api(tags = "分站管理——分站列表")
@RestController
@RequestMapping("/site")
@Slf4j
@SuppressWarnings("all")
public class SiteController {
    @Autowired
    private MkSiteBasicService mkSiteBasicService;
    @Autowired
    private CommonAPI commonAPI;

    @AutoLog(value="分站管理-分站列表数据查询")
    @ApiOperation(value = "分站管理-分站列表数据查询", notes = "分站管理-分站列表数据查询")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result<IPage<MkSiteBasic>> querySitePageList(MkSiteBasic siteBasic, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                    @RequestParam(name="pageSize", defaultValue="100") Integer pageSize, HttpServletRequest req) {
        Result<IPage<MkSiteBasic>> result = new Result<IPage<MkSiteBasic>>();
        Page<MkSiteBasic> page = new Page<MkSiteBasic>(pageNo, pageSize);
        IPage<MkSiteBasic> pageList = mkSiteBasicService.findAllSiteByNow(page,siteBasic);
        log.info("site--list--查询当前页："+pageList.getCurrent());
        log.info("site--list--查询当前页数量："+pageList.getSize());
        log.info("site--list--查询结果数量："+pageList.getRecords().size());
        log.info("site--list--数据总数："+pageList.getTotal());
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }

    @AutoLog(value="分站管理-分站列表—设置总部抽成比例和待结算时间以及（支付宝）提现账号")
    @ApiOperation(value = "分站管理-分站列表—设置总部抽成比例和待结算时间以及（支付宝）提现账号", notes = "分站管理-分站列表—设置总部抽成比例和待结算时间以及（支付宝）提现账号")
    @PostMapping(value = "/set")
    public Result siteSet(@RequestBody MkSiteBasic mkSiteBasic, HttpServletRequest req){
        Result result = new Result();
        int count = mkSiteBasicService.siteSet(mkSiteBasic);
        result.setSuccess(count>0 ? true : false);
        return result;
    }



}
